package edu.purdue.cs.cs505._final.server.client;

import java.math.BigInteger;
import java.util.ArrayList;

import edu.purdue.cs.cs505._final.server.GetShareStore;
import edu.purdue.cs.cs505._final.server.ServerStub;
import edu.purdue.cs.ds.ServerSets;
import edu.purdue.cs.ds.vss.Reconstructor;
import edu.purdue.cs.ds.vss.ShareStore;

public class Admin {
	
	public static void main(String[] args) throws Exception {
		int n = 3;
		int k = 1;
		ServerSets serverSets = new ServerSets(n, k);
		int l = serverSets.getL();
		
		ArrayList<ShareStore> stores = new ArrayList<ShareStore>();
		for(int i = 0; i < k+1; i ++) {
			ServerStub stub = new ServerStub("http://localhost:8080/axis2/services/server" + (i));
			System.out.println("Server " + (i+1));
			GetShareStore anyValue = new GetShareStore();
			anyValue.setIn("");
			String storeStr = stub.getShareStore(anyValue).getOut();
			
			ShareStore store = new ShareStore(storeStr);
			stores.add(store);
			
//			System.out.println(store);
		}
		
		
		Reconstructor recon = new Reconstructor();
		
		BigInteger tmpS = recon.reconstructSecretFromStores(stores, n, k);
		System.out.println(tmpS);
	}

}
